Compare commits
No commits in common. 'main' and 'lh_branch' have entirely different histories.
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/sky-take-out.iml" filepath="$PROJECT_DIR$/sky-take-out.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -1,77 +0,0 @@
|
||||
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());
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package com.sky.mapper;
|
||||
|
||||
import com.sky.entity.DishFlavor;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DishFlavorMapper {
|
||||
|
||||
/*
|
||||
* 批量插入口味数据
|
||||
* */
|
||||
void insertBatch(List<DishFlavor> flavors);
|
||||
|
||||
/*
|
||||
* 根据菜品id删除对应口味
|
||||
* */
|
||||
@Delete("delete from dish_flavor where dish_id = #{dishId}")
|
||||
void deleteByDishId(Long dishId);
|
||||
|
||||
/*
|
||||
* 根据菜品id集合批量删除关联的口味数据
|
||||
* */
|
||||
void deleteByDishIds(List<Long> dishIds);
|
||||
|
||||
/*
|
||||
* 根据菜品id返回口味数据
|
||||
* */
|
||||
@Select("select * from dish_flavor where dish_id = #{dishId}")
|
||||
List<DishFlavor> getByDishId(Long dishId);
|
||||
}
|
@ -1,76 +1,4 @@
|
||||
package com.sky.mapper;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.sky.annotation.AutoFill;
|
||||
import com.sky.dto.SetmealPageQueryDTO;
|
||||
import com.sky.entity.Setmeal;
|
||||
import com.sky.enumeration.OperationType;
|
||||
import com.sky.vo.DishItemVO;
|
||||
import com.sky.vo.SetmealVO;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface SetmealMapper {
|
||||
|
||||
/**
|
||||
* 根据分类id查询套餐的数量
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Select("select count(id) from setmeal where category_id = #{categoryId}")
|
||||
Integer countByCategoryId(Long id);
|
||||
|
||||
/*
|
||||
* 新增套餐
|
||||
* */
|
||||
@AutoFill(OperationType.INSERT)
|
||||
void insert(Setmeal setmeal);
|
||||
|
||||
Page<SetmealVO> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);
|
||||
|
||||
/*
|
||||
* 根据套餐id获取套餐数据
|
||||
* */
|
||||
@Select("select * from setmeal where id = #{id}")
|
||||
Setmeal getById(Long Id);
|
||||
|
||||
void deleteBatch(List<Long> ids);
|
||||
|
||||
|
||||
@AutoFill(OperationType.UPDATE)
|
||||
void updateWithDish(Setmeal setmeal);
|
||||
|
||||
@Update("update setmeal set status = #{status} where id = #{id}")
|
||||
void startOrStop(Setmeal setmeal);
|
||||
|
||||
/**
|
||||
* 动态条件查询套餐
|
||||
* @param setmeal
|
||||
* @return
|
||||
*/
|
||||
List<Setmeal> list(Setmeal setmeal);
|
||||
|
||||
|
||||
/**
|
||||
* 根据套餐id查询菜品选项
|
||||
* @param setmealId
|
||||
* @return
|
||||
*/
|
||||
@Select("select sd.name, sd.copies, d.image, d.description " +
|
||||
"from setmeal_dish sd left join dish d on sd.dish_id = d.id " +
|
||||
"where sd.setmeal_id = #{setmealId}")
|
||||
List<DishItemVO> getDishItemBySetmealId(Long setmealId);
|
||||
|
||||
/**
|
||||
* 根据条件统计套餐数量
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
Integer countByMap(Map map);
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
package com.sky.service;
|
||||
|
||||
import com.sky.dto.DishDTO;
|
||||
import com.sky.dto.DishPageQueryDTO;
|
||||
import com.sky.entity.Dish;
|
||||
import com.sky.result.PageResult;
|
||||
import com.sky.vo.DishVO;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DishService {
|
||||
|
||||
/*
|
||||
* 新增菜品和对应的口味
|
||||
* */
|
||||
void saveWithFlavor(DishDTO dishDTO);
|
||||
|
||||
/*
|
||||
* 菜品分页查询
|
||||
* */
|
||||
PageResult pageQuery(DishPageQueryDTO dishPageQueryDTO);
|
||||
|
||||
void deleteBatch(List<Long> ids);
|
||||
|
||||
|
||||
/*
|
||||
* 根据菜品id返回菜品和口味数据
|
||||
* */
|
||||
DishVO getById(Long id);
|
||||
|
||||
/*
|
||||
* 根据id修改菜品基本信息和对应口味信息
|
||||
* */
|
||||
void updateWithFlavor(DishDTO dishDTO);
|
||||
|
||||
List<Dish> getByCategoryId(Long categoryId);
|
||||
|
||||
/**
|
||||
* 条件查询菜品和口味
|
||||
* @param dish
|
||||
* @return
|
||||
*/
|
||||
List<DishVO> listWithFlavor(Dish dish);
|
||||
|
||||
|
||||
void startOrStop(Integer status, Integer id);
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 通过WebSocket每隔5秒向客户端发送消息
|
||||
*/
|
||||
// @Scheduled(cron = "0/5 * * * * ?")
|
||||
// public void sendMessageToClient() {
|
||||
// webSocketServer.sendToAllClient("这是来自服务端的消息:" + DateTimeFormatter.ofPattern("HH:mm:ss").format(LocalDateTime.now()));
|
||||
// }
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
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;
|
||||
|
||||
/*
|
||||
* 使用POI操作excel文件
|
||||
* */
|
||||
public class POITest {
|
||||
|
||||
/*
|
||||
* 通过POI创建excel文件并且写入文件内容
|
||||
* */
|
||||
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();
|
||||
}
|
||||
|
||||
/*
|
||||
* 通过POI读入excel文件中的内容
|
||||
* */
|
||||
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();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue