|
|
@@ -451,6 +451,8 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
resultMap.put("projectNum", projectNum);
|
|
|
}
|
|
|
|
|
|
+ alignGroupSummaryWithGroupRows(resultMap, userId, mediaType, startTime, endTime);
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -1988,6 +1990,43 @@ public class MaterialStareServiceImpl implements MaterialStareService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ private void alignGroupSummaryWithGroupRows(Map resultMap, String userId, String mediaType, String startTime, String endTime) {
|
|
|
+ if (resultMap == null || StringUtils.isBlank(userId) || StringUtils.isBlank(mediaType)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Result groupResult = getOperationGroupData(userId, mediaType, startTime, endTime, 1, 1000);
|
|
|
+ if (groupResult == null || !groupResult.isSuccess() || groupResult.getResult() == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Object rawPage = groupResult.getResult();
|
|
|
+ if (!(rawPage instanceof PageInfo)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ PageInfo<KuaiShouOperateGroupVo> pageInfo = (PageInfo<KuaiShouOperateGroupVo>) rawPage;
|
|
|
+ List<KuaiShouOperateGroupVo> rows = pageInfo.getList();
|
|
|
+ if (rows == null || rows.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ double sectionCost = rows.stream().filter(row -> row != null).mapToDouble(KuaiShouOperateGroupVo::getTotalCost).sum();
|
|
|
+ long totalOperationNum = rows.stream().filter(row -> row != null).mapToLong(KuaiShouOperateGroupVo::getOperationNum).sum();
|
|
|
+ long totalProjectNum = rows.stream().filter(row -> row != null).mapToLong(KuaiShouOperateGroupVo::getProjectNum).sum();
|
|
|
+ long totalAccountNum = rows.stream().filter(row -> row != null).mapToLong(KuaiShouOperateGroupVo::getAccountNum).sum();
|
|
|
+ double averagePeopleCost = totalOperationNum <= 0 ? 0D : sectionCost / totalOperationNum;
|
|
|
+ double averageAccountNum = totalOperationNum <= 0 ? 0D : (double) totalAccountNum / totalOperationNum;
|
|
|
+ DecimalFormat df = new DecimalFormat("#.000");
|
|
|
+ resultMap.put("sectionCost", new BigDecimal(sectionCost).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
+ resultMap.put("userAveragecost", averagePeopleCost == 0D ? 0 : df.format(averagePeopleCost));
|
|
|
+ resultMap.put("userAverageAccount", (int) Math.ceil(averageAccountNum));
|
|
|
+ resultMap.put("projectNum", String.valueOf(totalProjectNum));
|
|
|
+ long startDate = DateUtils.getDateInteger(startTime);
|
|
|
+ long endDate = DateUtils.getDateInteger(endTime);
|
|
|
+ long nowDate = DateUtils.getDateInteger(DateUtils.getDate("yyyy-MM-dd"));
|
|
|
+ if (startDate == endDate && startDate == nowDate) {
|
|
|
+ resultMap.put("todayCost", new BigDecimal(sectionCost).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private long buildAccountQueryStart(long startDate, long lastTimeStart, long startEqually, boolean includeEqually) {
|
|
|
long queryStartDate = Math.min(startDate, lastTimeStart);
|
|
|
if (includeEqually) {
|