|
|
|
@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.Comparator; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
@ -79,9 +80,6 @@ public class HomeServiceImpl implements HomeService{
|
|
|
|
|
//完成数
|
|
|
|
|
final Integer taskFinish = taskFinishList.stream().reduce(Integer::sum).orElse(0); |
|
|
|
|
|
|
|
|
|
log.info("taskFinish={}",taskFinish); |
|
|
|
|
log.info("taskExec={}",taskExec); |
|
|
|
|
|
|
|
|
|
if (taskFinish != null && taskFinish != 0) { |
|
|
|
|
double taskCompletionRate = (double) taskFinish/taskExec*100; |
|
|
|
|
homeCountResVO.setTaskCompletionRate(String.format("%.1f", taskCompletionRate)); |
|
|
|
@ -91,7 +89,6 @@ public class HomeServiceImpl implements HomeService{
|
|
|
|
|
|
|
|
|
|
//根据不同的身份查询
|
|
|
|
|
final List<HomeGroupCountVO> homeGroupCountVOS = taskInfoMapper.selectHomeGroupCount(homeSelectVO); |
|
|
|
|
|
|
|
|
|
List<HomeListVO> homeGroupCountVOS1 = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
if (homeGroupCountVOS != null && homeGroupCountVOS.size() > 0) { |
|
|
|
@ -99,20 +96,63 @@ public class HomeServiceImpl implements HomeService{
|
|
|
|
|
HomeListVO homeListVO = new HomeListVO(); |
|
|
|
|
homeListVO.setName(item.getName()); |
|
|
|
|
homeListVO.setValue(item.getCompletionRate()); |
|
|
|
|
double rate = (double) item.getFinishCount() /taskExec * 100; |
|
|
|
|
homeListVO.setPieValue(String.format("%.1f", rate)); |
|
|
|
|
// double rate = (double) item.getFinishCount() /taskExec * 100;
|
|
|
|
|
// homeListVO.setPieValue(String.format("%.1f", rate));
|
|
|
|
|
homeGroupCountVOS1.add(homeListVO); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//排序
|
|
|
|
|
final List<HomeListVO> sortCollect = homeGroupCountVOS1.stream(). |
|
|
|
|
sorted(Comparator.comparing(HomeListVO::getValue).reversed()). |
|
|
|
|
collect(Collectors.toList()); |
|
|
|
|
//循环饼图占比数据
|
|
|
|
|
|
|
|
|
|
final List<Double> collect = homeGroupCountVOS1.stream().filter(i -> !i.getValue().equals("0.0")). |
|
|
|
|
map(i -> Double.parseDouble(i.getValue())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
double total = collect.stream() |
|
|
|
|
.reduce(0.0, Double::sum); |
|
|
|
|
|
|
|
|
|
homeGroupCountVOS1.forEach(item->{ |
|
|
|
|
if (item != null && item.getValue() != null) { |
|
|
|
|
final double value = Double.parseDouble(item.getValue()); |
|
|
|
|
if (total != 0 && value != 0) { |
|
|
|
|
final double pieRate = value / total * 100; |
|
|
|
|
// 如果 TaskCompletionRate 不为空,则乘以该值
|
|
|
|
|
String taskCompletionRateStr = homeCountResVO.getTaskCompletionRate(); |
|
|
|
|
double taskCompletionRate = "0.0".equals(taskCompletionRateStr) ? 0.0 : Double.parseDouble(taskCompletionRateStr); |
|
|
|
|
final double pie = pieRate * taskCompletionRate / 100; |
|
|
|
|
item.setPieValue(String.format("%.1f", pie)); |
|
|
|
|
} else { |
|
|
|
|
item.setPieValue(String.format("%.1f", 0.0)); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
item.setPieValue(String.format("%.1f", 0.0)); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
log.info("sortCollect:{}", sortCollect); |
|
|
|
|
|
|
|
|
|
homeCountResVO.setCompletionRate(sortCollect); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//排序
|
|
|
|
|
final List<HomeListVO> sortedList = homeGroupCountVOS1.stream() |
|
|
|
|
.filter(item -> item.getValue() != null && !item.getValue().isEmpty()) // 过滤掉 null 或空字符串
|
|
|
|
|
.sorted(Comparator.comparing( |
|
|
|
|
item -> { |
|
|
|
|
try { |
|
|
|
|
return Double.parseDouble(item.getValue()); // 将字符串转为 double
|
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
return Double.MIN_VALUE; // 如果解析失败,视为最小值
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
)) // 升序排序
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
if (sortedList != null && sortedList.size() > 0) { |
|
|
|
|
List<HomeListVO> reversedList = new ArrayList<>(); |
|
|
|
|
for (int i = sortedList.size() - 1; i >= 0; i--) { |
|
|
|
|
reversedList.add(sortedList.get(i)); |
|
|
|
|
} |
|
|
|
|
homeCountResVO.setCompletionRate(reversedList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return homeCountResVO; |
|
|
|
|
} |
|
|
|
|