增加今日收益计算
This commit is contained in:
@ -31,6 +31,8 @@ public class AnnualOverviewResp {
|
||||
@ApiModelProperty(value = "年总充")
|
||||
BigDecimal yearCharge;
|
||||
|
||||
@ApiModelProperty(value = "今日收益")
|
||||
BigDecimal todayProfit;
|
||||
|
||||
@ApiModelProperty(value = "昨日收益")
|
||||
BigDecimal yestProfit;
|
||||
|
||||
@ -282,6 +282,7 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
annualOverviewResp.setYestProfit(overviewProfit.getYestProfit()==null?null:overviewProfit.getYestProfit().multiply(new BigDecimal("10000")));
|
||||
annualOverviewResp.setYearProfit(overviewProfit.getYearProfit()==null?null:overviewProfit.getYearProfit().multiply(new BigDecimal("10000")));
|
||||
annualOverviewResp.setTotalProfit(overviewProfit.getTotalProfit()==null?null:overviewProfit.getTotalProfit().multiply(new BigDecimal("10000")));
|
||||
annualOverviewResp.setTodayProfit(overviewProfit.getTodayProfit()==null?null:overviewProfit.getTodayProfit().multiply(new BigDecimal("10000")));
|
||||
//时间当年
|
||||
DateTime begin = DateUtil.beginOfYear(new Date());
|
||||
String beginString = DateUtil.format(begin, CommonConstant.DATE_YMD);
|
||||
@ -1532,7 +1533,7 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
if(beginDate == null){
|
||||
return annualOverviewResp;
|
||||
}
|
||||
Date date = DateUtil.yesterday();
|
||||
Date date = DateUtil.date();
|
||||
Date startDate = DateUtil.beginOfYear(beginDate);
|
||||
Date endDate = DateUtil.endOfDay(date);
|
||||
String begin = DateUtil.format(startDate, CommonConstant.DATE_YMD);
|
||||
@ -1546,6 +1547,7 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
profitList.add(dayProfitType);
|
||||
}
|
||||
}
|
||||
//计算总收益
|
||||
Map<String, List<DayProfitType>> dayMap = profitList.stream().collect(Collectors.groupingBy(DayProfitType::getDay));
|
||||
List<AnnualChartValue> yearProfitCurve = new ArrayList<>();
|
||||
getAnnualOverviewResp(yearProfitCurve, dateTimes, CommonConstant.DATE_Y, dayMap);
|
||||
@ -1554,6 +1556,7 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
yearProfit = yearProfit.add(chartValue.getProfit());
|
||||
}
|
||||
annualOverviewResp.setTotalProfit(yearProfit);
|
||||
//计算年收益
|
||||
startDate = DateUtil.beginOfYear(date);
|
||||
List<DateTime> nowDateTime = DateUtil.rangeToList(startDate, endDate, DateField.MONTH);
|
||||
List<AnnualChartValue> monthProfitCurve = new ArrayList<>();
|
||||
@ -1563,6 +1566,18 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
monthProfit = monthProfit.add(chartValue.getProfit());
|
||||
}
|
||||
annualOverviewResp.setYearProfit(monthProfit);
|
||||
// 计算今日收益
|
||||
List<DateTime> todayDateTime = DateUtil.rangeToList(endDate, endDate, DateField.DAY_OF_MONTH);
|
||||
List<AnnualChartValue> todayProfitCurve = new ArrayList<>();
|
||||
getAnnualOverviewResp(todayProfitCurve, todayDateTime, CommonConstant.DATE_YMD, dayMap);
|
||||
BigDecimal todayProfit = BigDecimal.ZERO;
|
||||
for (AnnualChartValue chartValue : todayProfitCurve) {
|
||||
todayProfit = todayProfit.add(chartValue.getProfit());
|
||||
}
|
||||
annualOverviewResp.setTodayProfit(todayProfit);
|
||||
// 计算昨日收益
|
||||
date = DateUtil.yesterday();
|
||||
endDate = DateUtil.endOfDay(date);
|
||||
List<DateTime> dayDateTime = DateUtil.rangeToList(endDate, endDate, DateField.DAY_OF_MONTH);
|
||||
List<AnnualChartValue> dayProfitCurve = new ArrayList<>();
|
||||
getAnnualOverviewResp(dayProfitCurve, dayDateTime, CommonConstant.DATE_YMD, dayMap);
|
||||
@ -1606,12 +1621,13 @@ public class IargeScreenShowServiceImpl implements IargeScreenShowService {
|
||||
}
|
||||
}
|
||||
BigDecimal result = dischargeProfit.subtract(chargeProfit).divide(new BigDecimal("10000"));
|
||||
if (result.doubleValue() > 0.0) {
|
||||
// if (result.doubleValue() > 0.0) {
|
||||
// annualChartValue.setProfit(result);
|
||||
// } else {
|
||||
// log.info("{},大屏计算收益,放电收益小于充电收益",day);
|
||||
// annualChartValue.setProfit(BigDecimal.ZERO);
|
||||
// }
|
||||
annualChartValue.setProfit(result);
|
||||
} else {
|
||||
log.info("{},大屏计算收益,放电收益小于充电收益",day);
|
||||
annualChartValue.setProfit(BigDecimal.ZERO);
|
||||
}
|
||||
annualChartValue.setTime(day);
|
||||
curveResult.add(annualChartValue);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user