From 83de4c20d8f665113c2e8b136231ba1d064ef4b6 Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 27 May 2021 10:59:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=97=E5=88=86=E8=AF=B4=E6=98=8E=20?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E5=88=86=E6=95=B0=E4=BF=9D=E7=95=99=E4=B8=80?= =?UTF-8?q?=E4=BD=8D=E5=B0=8F=E6=95=B0=EF=BC=8C=E6=9D=83=E9=87=8D=E4=BF=9D?= =?UTF-8?q?=E7=95=99=E6=95=B4=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index/result/IndexScoreDetailResult.java | 6 ++- .../index/result/IndexScoreResult.java | 8 +++- .../index/impl/IndexExplainServiceImpl.java | 45 ++++++++++++++----- .../fact/impl/FactIndexServiceImpl.java | 5 +++ .../fact/FactIndexAgencySubScoreDao.xml | 5 ++- .../mapper/fact/FactIndexCpcSubScoreDao.xml | 2 +- .../mapper/fact/FactIndexDeptSubScoreDao.xml | 2 +- 7 files changed, 56 insertions(+), 17 deletions(-) diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/index/result/IndexScoreDetailResult.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/index/result/IndexScoreDetailResult.java index 8b30af940f..cdec4cc3e9 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/index/result/IndexScoreDetailResult.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/index/result/IndexScoreDetailResult.java @@ -1,5 +1,6 @@ package com.epmet.evaluationindex.index.result; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; @@ -40,9 +41,10 @@ public class IndexScoreDetailResult implements Serializable { private String weight; /** - * 数量 + * 类型 取原始值 还是数量 */ - private String quantity; + @JsonIgnore + private String type; diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/index/result/IndexScoreResult.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/index/result/IndexScoreResult.java index c817b5de55..d6ca46a913 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/index/result/IndexScoreResult.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/index/result/IndexScoreResult.java @@ -32,9 +32,15 @@ public class IndexScoreResult implements Serializable { * 原始值 */ private String originValue; + /** * 数量 */ - private String quantity; + private String sampleCount; + + /** + * 值类型 + */ + private String valueType; } 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 5c8ceaf757..77252eb6ad 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 @@ -22,6 +22,7 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.enums.OrgLevelEnum; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.DataSourceConstant; +import com.epmet.datareport.constant.FactConstant; import com.epmet.datareport.constant.IndexConstant; import com.epmet.datareport.dao.evaluationindex.index.IndexExplainDao; import com.epmet.datareport.dao.evaluationindex.index.IndexGroupDetailDao; @@ -184,10 +185,10 @@ public class IndexExplainServiceImpl implements IndexExplainService { break; default: - log.error("暂不支持更高级别的查询,level:{}",orgLevel); + log.error("暂不支持更高级别的查询,level:{}", orgLevel); } - setRealValue(result.getTableDataList(), realScoreList); + setRealValue(result.getTableDataList(), realScoreList, tableHeaders); } } @@ -196,11 +197,12 @@ public class IndexExplainServiceImpl implements IndexExplainService { * * @param tableList * @param scoreList + * @param tableHeaders * @return void * @author LiuJanJun * @date 2021/5/19 2:07 下午 */ - private void setRealValue(List tableList, List scoreList) { + private void setRealValue(List tableList, List scoreList, List tableHeaders) { if (CollectionUtils.isEmpty(tableList) || CollectionUtils.isEmpty(scoreList)) { return; } @@ -209,19 +211,37 @@ public class IndexExplainServiceImpl implements IndexExplainService { if (!tb.getIndexCode().equals(score.getIndexCode())) { continue; } - tb.setOriginValue(score.getOriginValue()); tb.setScore(String.valueOf(score.getScore())); - if (StringUtils.isNotBlank(score.getQuantity())) { - tb.setQuantity(score.getQuantity()); + tb.setWeight(score.getWeight().multiply(new BigDecimal(NumConstant.ONE_HUNDRED)).setScale(0, BigDecimal.ROUND_HALF_UP) + "%"); + if (tableHeaders.contains("平均值")) { + if (StringUtils.isNotBlank(score.getSampleCount())) { + tb.setOriginValue(score.getSampleCount()); + } + } else { + tb.setOriginValue(score.getOriginValue()); + } + + + //小数类型,四舍五入保留小数点后一位 + if (FactConstant.INTEGER.equals(score.getValueType())) { + BigDecimal num = new BigDecimal(tb.getOriginValue()).setScale(0, BigDecimal.ROUND_HALF_UP); + tb.setOriginValue(num.toString()); + } + if (FactConstant.DECIMAL.equals(score.getValueType())) { + BigDecimal num = new BigDecimal(tb.getOriginValue()).setScale(1, BigDecimal.ROUND_HALF_UP); + tb.setOriginValue(num.toString()); + } + //百分数类型,四舍五入保留小数点后一位并转成百分比 + if (FactConstant.PERCENT.equals(score.getValueType())) { + BigDecimal num = new BigDecimal(tb.getOriginValue()).setScale(1, BigDecimal.ROUND_HALF_UP); + tb.setOriginValue(num + "%"); } - tb.setWeight(score.getWeight().multiply(new BigDecimal(NumConstant.ONE_HUNDRED)) + "%"); } } } private List setDefaultTableData(String orgLevel, String type, Map> detailEntityMap, IndexExplainResult result, String allIndexCodePath, List indexGroupDetailEntities) { - if (indexGroupDetailEntities == null) { indexGroupDetailEntities = detailEntityMap.get(allIndexCodePath); } @@ -236,15 +256,18 @@ public class IndexExplainServiceImpl implements IndexExplainService { if ("grid".equals(orgLevel) && IndexConstant.ZI_SHEN.equals(type) && index.getAllIndexCodePath().contains(IndexConstant.XIA_JI)) { return; } - if ((!"grid".equals(orgLevel) && !"district".equals(orgLevel)) && !index.getAllIndexCodePath().contains(type)) { + if ("district".equals(orgLevel) && !index.getAllIndexCodePath().contains(type) && !index.getAllIndexCodePath().contains(IndexConstant.ZHI_LI_NENG_LI)) { + return; + } + if (!"grid".equals(orgLevel) && !"district".equals(orgLevel) && !index.getAllIndexCodePath().contains(type)) { return; } table.setIndexCode(index.getIndexCode()); table.setIndexName(index.getIndexName()); table.setOriginValue(NumConstant.ZERO_STR); table.setScore(NumConstant.ZERO_STR); - table.setWeight(index.getWeight().multiply(new BigDecimal(100)).setScale(NumConstant.TWO, BigDecimal.ROUND_HALF_UP) + "%"); - table.setQuantity(NumConstant.ZERO_STR); + table.setWeight(index.getWeight().multiply(new BigDecimal(100)).setScale(0, BigDecimal.ROUND_HALF_UP) + "%"); + table.setType(type); tableList.add(table); if (new BigDecimal(-1).compareTo(index.getThreshold()) != 0) { threlodList.add(index.getIndexName().concat(String.format(IndexConstant.THRESHOLD_TEXT, index.getThreshold().intValue()))); diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java index 596b1e9dd6..7a5eeee0d1 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java @@ -335,6 +335,11 @@ public class FactIndexServiceImpl implements FactIndexService { resultList.forEach(result -> { list.stream().filter(dto -> dto.getIndexCode().equals(result.getKey())).forEach(l -> { result.setShowType(l.getValueType()); + //整数 + if (FactConstant.DECIMAL.equals(l.getValueType())) { + BigDecimal num = new BigDecimal(result.getValue()).setScale(0, BigDecimal.ROUND_HALF_UP); + result.setValue(num.toString()); + } //小数类型,四舍五入保留小数点后一位 if (FactConstant.DECIMAL.equals(l.getValueType())) { BigDecimal num = new BigDecimal(result.getValue()).setScale(1, BigDecimal.ROUND_HALF_UP); diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml index d1b1dafeea..aafd8dd25b 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml @@ -46,9 +46,12 @@ fact.index_code, IF(fact.origin_value='',0,IFNULL(fact.origin_value,0)) AS origin_value, round(fact.score,1) AS score, - round(fact.WEIGHT,2) AS weight + round(fact.WEIGHT,2) AS weight, + SAMPLE_COUNT, + dict.VALUE_TYPE FROM fact_index_agency_sub_score fact + LEFT JOIN index_dict dict ON fact.index_code = dict.index_code WHERE fact.del_flag = '0' AND fact.all_parent_index_code = #{allParentIndexCode} diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCpcSubScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCpcSubScoreDao.xml index 84ea0eca60..4e7171912d 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCpcSubScoreDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCpcSubScoreDao.xml @@ -29,7 +29,7 @@