This commit is contained in:
2024-03-14 14:14:27 +08:00

View File

@@ -277,6 +277,13 @@ public class AutoSendSalesIvt {
resultList.add(resultJson);
}
// 根据合计倒序排序
resultList = resultList.stream()
.sorted(Comparator.comparing(row -> row.getDoubleValue("day_sum")))
.collect(Collectors.toList());
Collections.reverse(resultList);
// 插入小计
JSONObject jsonMin = new JSONObject();
jsonMin.put("sales_man", "小计");
@@ -342,6 +349,29 @@ public class AutoSendSalesIvt {
resultListAll.add(jsonSum);
// 计算占比
JSONObject jsonPro = new JSONObject();
jsonPro.put("sales_man", "占比");
double day1_pro = NumberUtil.mul(NumberUtil.div(jsonSum.getDoubleValue("day1"), jsonSum.getDoubleValue("day_sum")), 100);
jsonPro.put("day1", NumberUtil.round(day1_pro, 2) + "%");
double day2_pro = NumberUtil.mul(NumberUtil.div(jsonSum.getDoubleValue("day2"), jsonSum.getDoubleValue("day_sum")), 100);
jsonPro.put("day2", NumberUtil.round(day2_pro, 2) + "%");
double day3_pro = NumberUtil.mul(NumberUtil.div(jsonSum.getDoubleValue("day3"), jsonSum.getDoubleValue("day_sum")), 100);
jsonPro.put("day3", NumberUtil.round(day3_pro, 2) + "%");
double day4_pro = NumberUtil.mul(NumberUtil.div(jsonSum.getDoubleValue("day4"), jsonSum.getDoubleValue("day_sum")), 100);
jsonPro.put("day4", NumberUtil.round(day4_pro, 2) + "%");
double day5_pro = NumberUtil.mul(NumberUtil.div(jsonSum.getDoubleValue("day5"), jsonSum.getDoubleValue("day_sum")), 100);
jsonPro.put("day5", NumberUtil.round(day5_pro, 2) + "%");
jsonPro.put("day_sum", "100%");
resultListAll.add(jsonPro);
JSONObject result = new JSONObject();
result.put("data", resultListAll);
resultSize.add(resultListAll.size()+1);