Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a5619f5300
|
|
@ -31,6 +31,7 @@ public class DataScreeningServiceImpl implements DataScreeningService {
|
||||||
private static final String ORDER = "Order";
|
private static final String ORDER = "Order";
|
||||||
private static final String PERSON = "Person";
|
private static final String PERSON = "Person";
|
||||||
private static final String DISH = "Dish";
|
private static final String DISH = "Dish";
|
||||||
|
private static final int MAX_LAST_DAY = -29;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取数据总览
|
* 获取数据总览
|
||||||
|
|
@ -39,10 +40,12 @@ public class DataScreeningServiceImpl implements DataScreeningService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult getDataScreeningModel() {
|
public AjaxResult getDataScreeningModel() {
|
||||||
|
int lastDay = -1;
|
||||||
List<SingleModelVO> list = new ArrayList<>();
|
List<SingleModelVO> list = new ArrayList<>();
|
||||||
String currentDate = DateUtils.getDate();
|
String currentDate = DateUtils.getDate();
|
||||||
String yesterday = getLastDate(-1);
|
String yesterday = getLastDate(-1);
|
||||||
|
//获取上一个有食堂订单的日期
|
||||||
|
yesterday = getLastDate(lastDay, yesterday);
|
||||||
// 查询各项数据
|
// 查询各项数据
|
||||||
addSingleItem("今日食堂营业额(元)", currentDate, yesterday, list, 11, TURNOVER);
|
addSingleItem("今日食堂营业额(元)", currentDate, yesterday, list, 11, TURNOVER);
|
||||||
addSingleItem("今日食堂订单量(个)", currentDate, yesterday, list, 11, ORDER);
|
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, -1, DISH);
|
||||||
addSingleItem("今日超市营业额(元)", currentDate, yesterday, list, 4, TURNOVER);
|
addSingleItem("今日超市营业额(元)", currentDate, yesterday, list, 4, TURNOVER);
|
||||||
addSingleItem("今日超市订单量(个)", currentDate, yesterday, list, 4, ORDER);
|
addSingleItem("今日超市订单量(个)", currentDate, yesterday, list, 4, ORDER);
|
||||||
|
|
||||||
return AjaxResult.success(list);
|
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) {
|
private void addSingleItem(String name, String currentDate, String yesterdayData, List<SingleModelVO> list, int orderType, String type) {
|
||||||
SingleModelVO today = fetchDataByType(currentDate, orderType, type);
|
SingleModelVO today = fetchDataByType(currentDate, orderType, type);
|
||||||
SingleModelVO yesterday = fetchDataByType(yesterdayData, orderType, type);
|
SingleModelVO yesterday = fetchDataByType(yesterdayData, orderType, type);
|
||||||
|
today.setLastDate(yesterdayData);
|
||||||
today.setName(name);
|
today.setName(name);
|
||||||
calculateRate(today, yesterday, type);
|
calculateRate(today, yesterday, type);
|
||||||
list.add(today);
|
list.add(today);
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,5 @@ public class SingleModelVO {
|
||||||
private BigDecimal num;
|
private BigDecimal num;
|
||||||
private String rate;
|
private String rate;
|
||||||
private String name;
|
private String name;
|
||||||
|
private String lastDate;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue