Browse Source

得分说明 保留分数保留一位小数,权重保留整数

dev_shibei_match
jianjun 4 years ago
parent
commit
83de4c20d8
  1. 6
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/index/result/IndexScoreDetailResult.java
  2. 8
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/index/result/IndexScoreResult.java
  3. 43
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/index/impl/IndexExplainServiceImpl.java
  4. 5
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/fact/impl/FactIndexServiceImpl.java
  5. 5
      epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml
  6. 2
      epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCpcSubScoreDao.xml
  7. 2
      epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexDeptSubScoreDao.xml

6
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;

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

43
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;
@ -187,7 +188,7 @@ public class IndexExplainServiceImpl implements IndexExplainService {
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<IndexScoreDetailResult> tableList, List<IndexScoreResult> scoreList) {
private void setRealValue(List<IndexScoreDetailResult> tableList, List<IndexScoreResult> scoreList, List<String> 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<IndexScoreDetailResult> setDefaultTableData(String orgLevel, String type, Map<String, List<IndexGroupDetailResult>> detailEntityMap,
IndexExplainResult result, String allIndexCodePath, List<IndexGroupDetailResult> 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())));

5
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);

5
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}

2
epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCpcSubScoreDao.xml

@ -29,7 +29,7 @@
<select id="selecCpcAvgScore" resultType="com.epmet.evaluationindex.index.result.IndexScoreResult">
SELECT
id, customer_id, agency_id, grid_id, year_id, month_id, user_id,
COUNT(*) quantity,
COUNT(*) SAMPLE_COUNT,
ROUND(AVG(score),1) score,
index_code, all_parent_index_code,
ROUND(weight,2) weight

2
epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexDeptSubScoreDao.xml

@ -10,7 +10,7 @@
id, customer_id, dept_id, agency_id, month_id,
origin_value,
index_code, all_parent_index_code, weight,
COUNT(*) quantity,
COUNT(*) SAMPLE_COUNT,
ROUND(AVG(score),1) score,
round(weight,2) AS weight
FROM fact_index_dept_sub_score

Loading…
Cancel
Save