Browse Source

三大能力乘上对应权重,四舍五入提出公共方法

master
zxc 5 years ago
parent
commit
650736038c
  1. 55
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java
  2. 30
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml
  3. 8
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataYearlyDao.xml

55
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java

@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Comparator;
@ -53,6 +54,10 @@ public class IndexServiceImpl implements IndexService {
if (null == yearAverageIndexResultDTO){
return new YearAverageIndexResultDTO();
}
yearAverageIndexResultDTO.setPartyDevAbility(getRound(yearAverageIndexResultDTO.getPartyDevAbility()));
yearAverageIndexResultDTO.setGovernAbility(getRound(yearAverageIndexResultDTO.getGovernAbility()));
yearAverageIndexResultDTO.setServiceAbility(getRound(yearAverageIndexResultDTO.getServiceAbility()));
yearAverageIndexResultDTO.setYearAverageIndex(getRound(yearAverageIndexResultDTO.getYearAverageIndex()));
return yearAverageIndexResultDTO;
}
@ -66,19 +71,23 @@ public class IndexServiceImpl implements IndexService {
@Override
public MonthPieChartResultDTO monthPieChart(MonthPieChartFormDTO monthPieChartFormDTO) {
MonthPieChartResultDTO monthPieChartResultDTO = screenIndexDataMonthlyDao.selectMonthPieChart(monthPieChartFormDTO.getAgencyId(),null);
MonthPieChartResultDTO pieChartDTO = screenIndexDataMonthlyDao.selectMonthPieChart(monthPieChartFormDTO.getAgencyId(),null);
if (null == pieChartDTO){
return new MonthPieChartResultDTO();
}
// 处理小数四舍五入
pieChartDTO.setPartyDevAbility(getRound(pieChartDTO.getPartyDevAbility()));
pieChartDTO.setGovernAbility(getRound(pieChartDTO.getGovernAbility()));
pieChartDTO.setServiceAbility(getRound(pieChartDTO.getServiceAbility()));
String monthId = dateUtils.getCurrentMonthId();
int time = NumConstant.TWELVE;
//保证获取月度指数数据的最大可能性
while(null == monthPieChartResultDTO && time > NumConstant.ONE){
while(null == pieChartDTO && time > NumConstant.ONE){
time--;
monthId = dateUtils.getPreviousMonthIdByDest(null,monthId);
monthPieChartResultDTO = screenIndexDataMonthlyDao.selectMonthPieChart(monthPieChartFormDTO.getAgencyId(),monthId);
pieChartDTO = screenIndexDataMonthlyDao.selectMonthPieChart(monthPieChartFormDTO.getAgencyId(),monthId);
}
if (null == monthPieChartResultDTO){
return new MonthPieChartResultDTO();
}
return monthPieChartResultDTO;
return pieChartDTO;
}
/**
@ -112,6 +121,13 @@ public class IndexServiceImpl implements IndexService {
result.setTotalIndexData(totalIndexData);
return result;
}
// 处理小数四舍五入
monthBarchartResults.forEach(barchart -> {
barchart.setPartyDevAbility(getRound(barchart.getPartyDevAbility()));
barchart.setGovernAbility(getRound(barchart.getGovernAbility()));
barchart.setServiceAbility(getRound(barchart.getServiceAbility()));
barchart.setIndexTotal(getRound(barchart.getIndexTotal()));
});
List<MonthBarchartResult> collect = monthBarchartResults.stream().sorted(Comparator.comparing(MonthBarchartResult::getMonthId)).collect(Collectors.toList());
//升序 当前月份在队尾
List<String> _ymList = dateUtils.getXpro().keySet().stream().collect(Collectors.toList());
@ -178,6 +194,13 @@ public class IndexServiceImpl implements IndexService {
if (CollectionUtils.isEmpty(subAgencyIndexRankResultDTOS)){
return new ArrayList<>();
}
// 小数四舍五入
subAgencyIndexRankResultDTOS.forEach(indexRank -> {
indexRank.setPartyDevAbility(getRound(indexRank.getPartyDevAbility()));
indexRank.setGovernAbility(getRound(indexRank.getGovernAbility()));
indexRank.setServiceAbility(getRound(indexRank.getServiceAbility()));
indexRank.setTotalIndex(getRound(indexRank.getTotalIndex()));
});
return subAgencyIndexRankResultDTOS;
}
@ -191,7 +214,25 @@ public class IndexServiceImpl implements IndexService {
} else if (ScreenConstant.MONTH_ID.equals(formDTO.getType())){
// 月(上一个月) 指数排行
subAgencyIndexRankResultDTOS = screenIndexDataMonthlyDao.selectAnNingSubAgencyIndexMonthlyRank(formDTO);
subAgencyIndexRankResultDTOS.forEach(rank -> {
rank.setPartyDevAbility(getRound(rank.getPartyDevAbility()));
rank.setGovernAbility(getRound(rank.getGovernAbility()));
rank.setServiceAbility(getRound(rank.getServiceAbility()));
rank.setTotalIndex(getRound(rank.getTotalIndex()));
});
}
return subAgencyIndexRankResultDTOS;
}
/**
* @Description 小数四舍五入
* @param d
* @author zxc
* @date 2020/9/14 2:01 下午
*/
public Double getRound(Double d){
BigDecimal bigDecimal = new BigDecimal(d);
BigDecimal b = bigDecimal.setScale(NumConstant.ONE, BigDecimal.ROUND_HALF_UP);
return Double.valueOf(b.toString());
}
}

30
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml

@ -6,9 +6,9 @@
<!-- 2、月度指数分析-饼状图 -->
<select id="selectMonthPieChart" resultType="com.epmet.evaluationindex.screen.dto.result.MonthPieChartResultDTO">
SELECT
ROUND(service_ablity,1) AS serviceAbility,
ROUND(party_dev_ablity,1) AS partyDevAbility,
ROUND(govern_ablity,1) AS governAbility
service_ablity * SERVICE_ABLITY_WEIGHT AS serviceAbility,
party_dev_ablity * PARTY_DEV_WEIGHT AS partyDevAbility,
govern_ablity * GOVERN_ABLITY_WEIGHT AS governAbility
FROM
screen_index_data_monthly
WHERE
@ -30,10 +30,10 @@
<select id="selectMonthBarchart" resultType="com.epmet.evaluationindex.screen.dto.result.MonthBarchartResult">
SELECT
month_id AS monthId,
ROUND(service_ablity,1) AS serviceAbility,
ROUND(party_dev_ablity,1) AS partyDevAbility,
ROUND(govern_ablity,1) AS governAbility,
ROUND(index_total,1) AS indexTotal
service_ablity * SERVICE_ABLITY_WEIGHT AS serviceAbility,
party_dev_ablity * PARTY_DEV_WEIGHT AS partyDevAbility,
govern_ablity * GOVERN_ABLITY_WEIGHT AS governAbility,
(service_ablity * SERVICE_ABLITY_WEIGHT + party_dev_ablity * PARTY_DEV_WEIGHT + govern_ablity * GOVERN_ABLITY_WEIGHT) AS indexTotal
FROM
screen_index_data_monthly
WHERE
@ -47,10 +47,10 @@
<select id="selectSubAgencyIndexRank" parameterType="com.epmet.evaluationindex.screen.dto.form.SubAgencyIndexRankFormDTO" resultType="com.epmet.evaluationindex.screen.dto.result.SubAgencyIndexRankResultDTO">
SELECT
org_name AS NAME,
ROUND(index_total,1) AS totalIndex,
ROUND(govern_ablity,1) AS governAbility,
ROUND(party_dev_ablity,1) AS partyDevAbility,
ROUND(service_ablity,1) AS serviceAbility
index_total AS totalIndex,
govern_ablity AS governAbility,
party_dev_ablity AS partyDevAbility,
service_ablity AS serviceAbility
FROM
screen_index_data_yearly
WHERE
@ -66,10 +66,10 @@
resultType="com.epmet.evaluationindex.screen.dto.result.AnNingSubAgencyIndexRankResultDTO">
SELECT
org_name AS `NAME`,
ROUND(index_total, 1) AS totalIndex,
ROUND(govern_ablity, 1) AS governAbility,
ROUND(party_dev_ablity, 1) AS partyDevAbility,
ROUND(service_ablity, 1) AS serviceAbility,
service_ablity * SERVICE_ABLITY_WEIGHT AS serviceAbility,
party_dev_ablity * PARTY_DEV_WEIGHT AS partyDevAbility,
govern_ablity * GOVERN_ABLITY_WEIGHT AS governAbility,
(service_ablity * SERVICE_ABLITY_WEIGHT + party_dev_ablity * PARTY_DEV_WEIGHT + govern_ablity * GOVERN_ABLITY_WEIGHT) AS totalIndex,
ORG_ID orgId
FROM
screen_index_data_monthly

8
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataYearlyDao.xml

@ -6,10 +6,10 @@
<!-- 1、年度平均指数 -->
<select id="selectYearAverageIndex" resultType="com.epmet.evaluationindex.screen.dto.result.YearAverageIndexResultDTO">
SELECT
ROUND(index_total,1) AS yearAverageIndex,
ROUND(service_ablity,1) AS serviceAbility,
ROUND(party_dev_ablity,1) AS partyDevAbility,
ROUND(govern_ablity,1) AS governAbility
index_total AS yearAverageIndex,
service_ablity AS serviceAbility,
party_dev_ablity AS partyDevAbility,
govern_ablity AS governAbility
FROM
screen_index_data_yearly
WHERE

Loading…
Cancel
Save