|
|
@ -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()); |
|
|
|
} |
|
|
|
} |
|
|
|