Merge remote-tracking branch 'origin/main'

hk_branch
lh 7 months ago
commit f41a5b20ec

@ -0,0 +1,74 @@
package com.sky.controller.admin;
import com.sky.result.Result;
import com.sky.service.ReportService;
import com.sky.vo.OrderReportVO;
import com.sky.vo.SalesTop10ReportVO;
import com.sky.vo.TurnoverReportVO;
import com.sky.vo.UserReportVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate;
@RestController
@RequestMapping("/admin/report")
@Api("数据统计相关接口")
@Slf4j
public class ReportController {
@Autowired
private ReportService reportService;
/*
*
*/
@GetMapping("/turnoverStatistics")
@ApiOperation("营业额统计")
public Result<TurnoverReportVO> turnoverStatistics
(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
log.info("营业额数据统计:{}{}",begin,end);
TurnoverReportVO turnoverStatistics = reportService.getTurnoverStatistics(begin, end);
return Result.success(turnoverStatistics);
}
@GetMapping("/userStatistics")
@ApiOperation("用户统计")
public Result<UserReportVO> userStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
log.info("用户统计:{}{}",begin,end);
UserReportVO userReportVO = reportService.getUserStatistics(begin,end);
return Result.success(userReportVO);
}
@ApiOperation("订单统计")
@GetMapping("/ordersStatistics")
public Result<OrderReportVO> orderStatistics(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
log.info("订单统计:{}{}",begin,end);
OrderReportVO orderReportVO = reportService.getOrderStatistics(begin,end);
return Result.success(orderReportVO);
}
@GetMapping("/top10")
@ApiOperation("查询销售排名top10")
public Result<SalesTop10ReportVO> top10(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
log.info("查询销量排名top10{}{}",begin,end);
SalesTop10ReportVO salesTop10ReportVO = reportService.getTop10(begin,end);
return Result.success(salesTop10ReportVO);
}
@GetMapping("export")
@ApiOperation("导出运营输出报表")
public void export(HttpServletResponse response){
reportService.exportBusinessData(response);
}
}

@ -0,0 +1,77 @@
package com.sky.controller.admin;
import com.sky.result.Result;
import com.sky.service.WorkspaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.time.LocalTime;
/**
*
*/
@RestController
@RequestMapping("/admin/workspace")
@Slf4j
@Api(tags = "工作台相关接口")
public class WorkSpaceController {
@Autowired
private WorkspaceService workspaceService;
/**
*
* @return
*/
@GetMapping("/businessData")
@ApiOperation("工作台今日数据查询")
public Result<BusinessDataVO> businessData(){
//获得当天的开始时间
LocalDateTime begin = LocalDateTime.now().with(LocalTime.MIN);
//获得当天的结束时间
LocalDateTime end = LocalDateTime.now().with(LocalTime.MAX);
BusinessDataVO businessDataVO = workspaceService.getBusinessData(begin, end);
return Result.success(businessDataVO);
}
/**
*
* @return
*/
@GetMapping("/overviewOrders")
@ApiOperation("查询订单管理数据")
public Result<OrderOverViewVO> orderOverView(){
return Result.success(workspaceService.getOrderOverView());
}
/**
*
* @return
*/
@GetMapping("/overviewDishes")
@ApiOperation("查询菜品总览")
public Result<DishOverViewVO> dishOverView(){
return Result.success(workspaceService.getDishOverView());
}
/**
*
* @return
*/
@GetMapping("/overviewSetmeals")
@ApiOperation("查询套餐总览")
public Result<SetmealOverViewVO> setmealOverView(){
return Result.success(workspaceService.getSetmealOverView());
}
}

@ -0,0 +1,23 @@
package com.sky.task;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Date;
/*
*
* */
@Component
@Slf4j
public class MyTask {
/*
* 5
* */
// @Scheduled(cron = "0/5 * * * * ?")
public void executeTask(){
log.info("定时任务开始执行:{}",new Date());
}
}

@ -0,0 +1,56 @@
package com.sky.task;
import com.sky.entity.Orders;
import com.sky.mapper.OrderMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.List;
@Component
@Slf4j
public class OrderTask {
@Autowired
private OrderMapper orderMapper;
/*
*
* */
@Scheduled(cron = "0 * * * * ? ") //每分钟触发一次
// @Scheduled(cron = "1/5 * * * * ?")
public void processTimeoutOrder(){
log.info("定时处理超时订单:{}", LocalDateTime.now());
LocalDateTime time = LocalDateTime.now().plusMinutes(-15);
List<Orders> orderList = orderMapper.getByStatusAndOrderTimeLT(Orders.PENDING_PAYMENT, time);
if(orderList != null || orderList.size() >0){
for (Orders orders : orderList) {
orders.setStatus(Orders.CANCELLED);
orders.setCancelReason("订单超时,自动取消");
orders.setCancelTime(LocalDateTime.now());
orderMapper.update(orders);
}
}
}
/*
*
* */
@Scheduled(cron = "0 0 1 * * ? ")//每日凌晨一点触发
// @Scheduled(cron = "0/5 * * * * ?")
public void processDeliveryOrder(){
log.info("定时处理处于派送中的订单:{}",LocalDateTime.now());
LocalDateTime time = LocalDateTime.now().plusMinutes(-60);
List<Orders> orderList = orderMapper.getByStatusAndOrderTimeLT(Orders.DELIVERY_IN_PROGRESS, time);
if(orderList != null || orderList.size() >0){
for (Orders orders : orderList) {
orders.setStatus(Orders.COMPLETED);
orderMapper.update(orders);
}
}
}
}

@ -0,0 +1,19 @@
package com.sky.task;
import com.sky.websocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class WebSocketTask {
@Autowired
private WebSocketServer webSocketServer;
/**
* WebSocket5
*/
// @Scheduled(cron = "0/5 * * * * ?")
// public void sendMessageToClient() {
// webSocketServer.sendToAllClient("这是来自服务端的消息:" + DateTimeFormatter.ofPattern("HH:mm:ss").format(LocalDateTime.now()));
// }
}

@ -0,0 +1,73 @@
package com.sky.test;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
/*
* 使POIexcel
* */
public class POITest {
/*
* POIexcel
* */
public static void write() throws IOException {
//在内存中创建一个excel文件
XSSFWorkbook excel = new XSSFWorkbook();
//在excel文件中创建一个sheet页
XSSFSheet sheet = excel.createSheet("info");
//在sheet页中创建行对象,rownum从0开始
XSSFRow row = sheet.createRow(1);
//创建单元格,写入文件内容
row.createCell(1).setCellValue("姓名");
row.createCell(2).setCellValue("城市");
//创建一个新行
row = sheet.createRow(2);
row.createCell(1).setCellValue("aiming");
row.createCell(2).setCellValue("北京");
//通过输出流将内存中的excel文件写入磁盘中
FileOutputStream out = new FileOutputStream(new File("D:\\info.xlsx"));
excel.write(out);
//关闭资源
out.close();
excel.close();
}
/*
* POIexcel
* */
public static void read() throws Exception{
FileInputStream in = new FileInputStream(new File("D:\\info.xlsx"));
//读取磁盘上已存在的excel文件
XSSFWorkbook excel = new XSSFWorkbook(in);
//读取excel文件中第一个sheet页
XSSFSheet sheet = excel.getSheetAt(0);
//获取sheet页中最后一行的行号
int lastRowNum = sheet.getLastRowNum();
for(int i = 1; i <= lastRowNum; i++){
//获取某一行
XSSFRow row = sheet.getRow(i);
//获得单元格对象
String cellValue1 = row.getCell(1).getStringCellValue();
String cellValue2 = row.getCell(2).getStringCellValue();
System.out.println(cellValue1 + " " + cellValue2);
}
//关闭资源
excel.close();
in.close();
}
public static void main(String[] args) throws Exception {
// write();
read();
}
}
Loading…
Cancel
Save