食堂数据总览-逻辑变更
This commit is contained in:
parent
20541f800d
commit
8a939b61a4
|
|
@ -31,6 +31,7 @@ public class DataScreeningServiceImpl implements DataScreeningService {
|
|||
private static final String ORDER = "Order";
|
||||
private static final String PERSON = "Person";
|
||||
private static final String DISH = "Dish";
|
||||
private static final int MAX_LAST_DAY = -29;
|
||||
|
||||
/**
|
||||
* 获取数据总览
|
||||
|
|
@ -39,10 +40,12 @@ public class DataScreeningServiceImpl implements DataScreeningService {
|
|||
*/
|
||||
@Override
|
||||
public AjaxResult getDataScreeningModel() {
|
||||
int lastDay = -1;
|
||||
List<SingleModelVO> list = new ArrayList<>();
|
||||
String currentDate = DateUtils.getDate();
|
||||
String yesterday = getLastDate(-1);
|
||||
|
||||
//获取上一个有食堂订单的日期
|
||||
yesterday = getLastDate(lastDay, yesterday);
|
||||
// 查询各项数据
|
||||
addSingleItem("今日食堂营业额(元)", currentDate, yesterday, list, 11, TURNOVER);
|
||||
addSingleItem("今日食堂订单量(个)", currentDate, yesterday, list, 11, ORDER);
|
||||
|
|
@ -50,10 +53,27 @@ public class DataScreeningServiceImpl implements DataScreeningService {
|
|||
addSingleItem("今日菜品数量(个)", currentDate, yesterday, list, -1, DISH);
|
||||
addSingleItem("今日超市营业额(元)", currentDate, yesterday, list, 4, TURNOVER);
|
||||
addSingleItem("今日超市订单量(个)", currentDate, yesterday, list, 4, ORDER);
|
||||
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上一个有食堂订单的日期
|
||||
*
|
||||
* @param lastDay 昨日日期
|
||||
* @return 昨日日期
|
||||
*/
|
||||
private String getLastDate(int lastDay, String yesterday) {
|
||||
while (lastDay >= MAX_LAST_DAY) {
|
||||
yesterday = getLastDate(lastDay);
|
||||
SingleModelVO yesterdayVO = fetchDataByType(yesterday, 11, TURNOVER);
|
||||
if (yesterdayVO.getNum().compareTo(BigDecimal.ZERO) != 0) {
|
||||
break;
|
||||
}
|
||||
lastDay--;
|
||||
}
|
||||
return yesterday;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加单项数据
|
||||
*
|
||||
|
|
@ -67,7 +87,7 @@ public class DataScreeningServiceImpl implements DataScreeningService {
|
|||
private void addSingleItem(String name, String currentDate, String yesterdayData, List<SingleModelVO> list, int orderType, String type) {
|
||||
SingleModelVO today = fetchDataByType(currentDate, orderType, type);
|
||||
SingleModelVO yesterday = fetchDataByType(yesterdayData, orderType, type);
|
||||
|
||||
today.setLastDate(yesterdayData);
|
||||
today.setName(name);
|
||||
calculateRate(today, yesterday, type);
|
||||
list.add(today);
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@ public class SingleModelVO {
|
|||
private BigDecimal num;
|
||||
private String rate;
|
||||
private String name;
|
||||
private String lastDate;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue