|
|
@ -184,7 +184,9 @@ public class WorkbenchServiceImpl implements WorkbenchService { |
|
|
|
|
|
|
|
// 周环比、日同比 |
|
|
|
card.setWow(calculateWeekOverWeek(market, currentDate)); |
|
|
|
card.setSumWow(calculateAllWeekOverWeek(date)); |
|
|
|
card.setDaily(calculateDayOverDay(market, currentDate)); |
|
|
|
card.setSumDaily(calculateAllDayOverDay(date)); |
|
|
|
} |
|
|
|
return card; |
|
|
|
} |
|
|
@ -260,28 +262,33 @@ public class WorkbenchServiceImpl implements WorkbenchService { |
|
|
|
return (int) Math.round(rate); |
|
|
|
} |
|
|
|
// 计算所有市场总体日环比 |
|
|
|
/* @Override |
|
|
|
@Override |
|
|
|
public Integer calculateAllDayOverDay(Date date) { |
|
|
|
//获取起止时间为当天零点与最后一秒 |
|
|
|
//获取今天的开始时间和结束时间 |
|
|
|
LocalDateTime startTime = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().with(LocalTime.MIN); |
|
|
|
LocalDateTime endTime= startTime.plusDays(1).minusSeconds(1); |
|
|
|
//获取地区列表 |
|
|
|
List<String> markets = generalService.getMarket(); |
|
|
|
int currentTotal = 0; //今日所有地区总的充值人数 |
|
|
|
int yesterdayTotal = 0; //昨日所有地区总的充值人数 |
|
|
|
|
|
|
|
//int currentTotalRechargeNum = statisticsMapper.countAllMarketRechargeNum( |
|
|
|
Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant()), |
|
|
|
Date.from(endTime.atZone(ZoneId.systemDefault()).toInstant())); |
|
|
|
|
|
|
|
if (currentTotalRechargeNum == 0) return 0; // 避免除以零的情况 |
|
|
|
|
|
|
|
Date yesterday = addDays(date, -1); // 昨天 |
|
|
|
int yesterdayTotalRechargeNum = statisticsMapper.countAllMarketRechargeNum( |
|
|
|
Date.from(yesterday.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().with(LocalTime.MIN).atZone(ZoneId.systemDefault()).toInstant()), |
|
|
|
Date.from(yesterday.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().with(LocalTime.MAX).atZone(ZoneId.systemDefault()).toInstant())); |
|
|
|
|
|
|
|
if (yesterdayTotalRechargeNum == 0) return 0; // 避免除以零的情况 |
|
|
|
Date yesterday = addDays(date, -1); |
|
|
|
//过去昨天的开始时间和结束时间 |
|
|
|
LocalDateTime ydayStartTime = yesterday.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().with(LocalTime.MIN); |
|
|
|
LocalDateTime ydayEndTime= ydayStartTime.plusDays(1).minusSeconds(1); |
|
|
|
for (String market : markets) { |
|
|
|
currentTotal += statisticsMapper.countRechargeNum(market, |
|
|
|
Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant()), |
|
|
|
Date.from(endTime.atZone(ZoneId.systemDefault()).toInstant())); |
|
|
|
yesterdayTotal += statisticsMapper.countRechargeNum(market, |
|
|
|
Date.from(ydayStartTime.atZone(ZoneId.systemDefault()).toInstant()), |
|
|
|
Date.from(ydayEndTime.atZone(ZoneId.systemDefault()).toInstant())); |
|
|
|
} |
|
|
|
if (yesterdayTotal == 0) return 0; // 避免除以零的情况 |
|
|
|
|
|
|
|
double rate = ((double)(currentTotalRechargeNum - yesterdayTotalRechargeNum) / yesterdayTotalRechargeNum) * 100; |
|
|
|
double rate = ((double)(currentTotal - yesterdayTotal) / yesterdayTotal) * 100; |
|
|
|
return (int)Math.round(rate); |
|
|
|
}*/ |
|
|
|
} |
|
|
|
/* |
|
|
|
获取该日期该市场的周环比 |
|
|
|
*/ |
|
|
@ -291,6 +298,7 @@ public class WorkbenchServiceImpl implements WorkbenchService { |
|
|
|
Date thisWeekStart = getStartOfWeek(date); |
|
|
|
//获取传入日期上一周的周一 |
|
|
|
Date lastWeekStart = addDays(thisWeekStart, -7); |
|
|
|
|
|
|
|
// 获取本周周一至今天的充值人数总和 |
|
|
|
int thisWeekTotal = statisticsMapper.countRechargeNum(market, thisWeekStart, date); |
|
|
|
// 获取上周同一时间段的充值人数总和 |
|
|
@ -301,6 +309,32 @@ public class WorkbenchServiceImpl implements WorkbenchService { |
|
|
|
double rate = ((double) (thisWeekTotal - lastWeekTotal) / lastWeekTotal) * 100; |
|
|
|
return (int) Math.round(rate); |
|
|
|
} |
|
|
|
/* |
|
|
|
获取改天总体的的周环比 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Integer calculateAllWeekOverWeek( Date date) { |
|
|
|
|
|
|
|
List<String> markets = generalService.getMarket(); |
|
|
|
int thisWeekTotal = 0; //本周至当天充值人数 |
|
|
|
int lastWeekTotal = 0; //上周至当天充值人数 |
|
|
|
//获取本周周一 |
|
|
|
Date thisWeekStart = getStartOfWeek(date); |
|
|
|
//获取传入日期上一周的周一 |
|
|
|
Date lastWeekStart = addDays(thisWeekStart, -7); |
|
|
|
for (String market : markets) { |
|
|
|
// 获取本周周一至今天的充值人数总和 |
|
|
|
thisWeekTotal += statisticsMapper.countRechargeNum(market, thisWeekStart, date); |
|
|
|
// 获取上周同一时间段的充值人数总和 |
|
|
|
lastWeekTotal += statisticsMapper.countRechargeNum(market, lastWeekStart, addDays(date, -7)); |
|
|
|
} |
|
|
|
|
|
|
|
if (lastWeekTotal == 0) { |
|
|
|
return 0; // 避免除以零的情况 |
|
|
|
} |
|
|
|
double rate = ((double) (thisWeekTotal - lastWeekTotal) / lastWeekTotal) * 100; |
|
|
|
return (int) Math.round(rate); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Date addDays(Date date, int days) { |
|
|
|