|
|
@ -14,7 +14,9 @@ import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.text.NumberFormat; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
@ -187,12 +189,19 @@ public class TopicServiceImpl implements TopicService { |
|
|
|
TopicShiftedCountResultDTO shiftedCount = topicDao.getShiftedCount(agencyId); |
|
|
|
if (topicSummaryInfo.size() != NumConstant.ZERO && shiftedCount != null) { |
|
|
|
Integer collect = topicSummaryInfo.stream().collect(Collectors.summingInt(TopicSummaryInfoResultDTO::getValue)); |
|
|
|
DecimalFormat decimalFormat = new DecimalFormat(".00"); |
|
|
|
String ratio; |
|
|
|
ratio = collect == NumConstant.ZERO ? NumConstant.ZERO + TopicConstant.RATIO : decimalFormat.format(((float) shiftedCount.getShiftedIssueCount() / (float) collect) * NumConstant.ONE_HUNDRED) + TopicConstant.RATIO; |
|
|
|
topicSummaryInfo.forEach(topic -> { |
|
|
|
String s = topic.getPro().setScale(NumConstant.TWO, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString(); |
|
|
|
topic.setRatio(s.concat(TopicConstant.RATIO)); |
|
|
|
}); |
|
|
|
TopicSummaryInfoResultDTO result = new TopicSummaryInfoResultDTO(); |
|
|
|
if (collect == NumConstant.ZERO){ |
|
|
|
result.setRatio(NumConstant.ZERO+TopicConstant.RATIO); |
|
|
|
}else { |
|
|
|
BigDecimal bigDecimal = new BigDecimal(((float) shiftedCount.getShiftedIssueCount() / (float) collect) * NumConstant.ONE_HUNDRED); |
|
|
|
String s = bigDecimal.setScale(NumConstant.TWO, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString(); |
|
|
|
result.setRatio(s.concat(TopicConstant.RATIO)); |
|
|
|
} |
|
|
|
result.setName(TopicConstant.SHIFTED); |
|
|
|
result.setRatio(ratio); |
|
|
|
result.setValue(shiftedCount.getShiftedIssueCount()); |
|
|
|
topicSummaryInfo.add(result); |
|
|
|
} |
|
|
|