食堂门店
This commit is contained in:
@ -1,12 +1,18 @@
|
|||||||
package cn.iocoder.yudao.module.member.controller.admin.excelImport;
|
package cn.iocoder.yudao.module.member.controller.admin.excelImport;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.excelImport.vo.RechargeExcel;
|
import cn.iocoder.yudao.module.member.controller.admin.excelImport.vo.*;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.excelImport.vo.RechargeExcelListener;
|
import cn.iocoder.yudao.module.member.controller.admin.storegoods.vo.StoreGoodsSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.storegoodstype.StoreGoodsTypeDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
import cn.iocoder.yudao.module.member.service.amount.CashRechargeService;
|
import cn.iocoder.yudao.module.member.service.amount.CashRechargeService;
|
||||||
|
import cn.iocoder.yudao.module.member.service.storegoods.StoreGoodsService;
|
||||||
|
import cn.iocoder.yudao.module.member.service.storegoodstype.StoreGoodsTypeService;
|
||||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
|
import cn.iocoder.yudao.module.system.api.dish.DishesApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.dish.dto.DishExcelDto;
|
||||||
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.EasyExcel;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -35,6 +41,12 @@ public class ExcelImportController {
|
|||||||
private MemberUserService memberUserService;
|
private MemberUserService memberUserService;
|
||||||
@Resource
|
@Resource
|
||||||
private CashRechargeService cashRechargeService;
|
private CashRechargeService cashRechargeService;
|
||||||
|
@Resource
|
||||||
|
private DishesApi dishesApi;
|
||||||
|
@Resource
|
||||||
|
StoreGoodsService storeGoodsService;
|
||||||
|
@Resource
|
||||||
|
StoreGoodsTypeService storeGoodsTypeService;
|
||||||
|
|
||||||
@PostMapping("/easyExcelImport")
|
@PostMapping("/easyExcelImport")
|
||||||
public void importExcel(MultipartFile file, HttpServletResponse response,Long storeId) {
|
public void importExcel(MultipartFile file, HttpServletResponse response,Long storeId) {
|
||||||
@ -94,4 +106,90 @@ public class ExcelImportController {
|
|||||||
return notExist;
|
return notExist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/dishImport")
|
||||||
|
public void importExcelDish(MultipartFile file,Long storeId) {
|
||||||
|
if (!file.isEmpty()) {
|
||||||
|
//文件名称
|
||||||
|
int begin = Objects.requireNonNull(file.getOriginalFilename()).indexOf(".");
|
||||||
|
//文件名称长度
|
||||||
|
int last = file.getOriginalFilename().length();
|
||||||
|
//判断文件格式是否正确
|
||||||
|
String fileName = file.getOriginalFilename().substring(begin, last);
|
||||||
|
if (!fileName.endsWith(".xls") && !fileName.endsWith(".xlsx")) {
|
||||||
|
throw new IllegalArgumentException("上传文件格式错误");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("文件不能为空");
|
||||||
|
}
|
||||||
|
try (InputStream inputStream = file.getInputStream()) {
|
||||||
|
dishRead(inputStream,storeId);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dishRead(InputStream inputStream,Long storeId) {
|
||||||
|
//获取正确数据
|
||||||
|
ArrayList<DishExcel> successArrayList = new ArrayList<>();
|
||||||
|
EasyExcel.read(inputStream)
|
||||||
|
.head(DishExcel.class)
|
||||||
|
.registerReadListener(new DishExcelListener(
|
||||||
|
// 监听器中doAfterAllAnalysed执行此方法;所有读取完成之后处理逻辑
|
||||||
|
successArrayList::addAll))
|
||||||
|
// 设置sheet,默认读取第一个
|
||||||
|
.sheet()
|
||||||
|
// 设置标题(字段列表)所在行数
|
||||||
|
.headRowNumber(1)
|
||||||
|
.doRead();
|
||||||
|
dishesApi.exportDish(BeanUtils.toBean(successArrayList, DishExcelDto.class),storeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/GoodsImport")
|
||||||
|
public void importExcelGoods(MultipartFile file,Long storeId) {
|
||||||
|
if (!file.isEmpty()) {
|
||||||
|
//文件名称
|
||||||
|
int begin = Objects.requireNonNull(file.getOriginalFilename()).indexOf(".");
|
||||||
|
//文件名称长度
|
||||||
|
int last = file.getOriginalFilename().length();
|
||||||
|
//判断文件格式是否正确
|
||||||
|
String fileName = file.getOriginalFilename().substring(begin, last);
|
||||||
|
if (!fileName.endsWith(".xls") && !fileName.endsWith(".xlsx")) {
|
||||||
|
throw new IllegalArgumentException("上传文件格式错误");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("文件不能为空");
|
||||||
|
}
|
||||||
|
try (InputStream inputStream = file.getInputStream()) {
|
||||||
|
GoodsRead(inputStream,storeId);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GoodsRead(InputStream inputStream,Long storeId) {
|
||||||
|
//获取正确数据
|
||||||
|
ArrayList<GoodsExcel> successArrayList = new ArrayList<>();
|
||||||
|
EasyExcel.read(inputStream)
|
||||||
|
.head(GoodsExcel.class)
|
||||||
|
.registerReadListener(new GoodsExcelListener(
|
||||||
|
// 监听器中doAfterAllAnalysed执行此方法;所有读取完成之后处理逻辑
|
||||||
|
successArrayList::addAll))
|
||||||
|
// 设置sheet,默认读取第一个
|
||||||
|
.sheet()
|
||||||
|
// 设置标题(字段列表)所在行数
|
||||||
|
.headRowNumber(1)
|
||||||
|
.doRead();
|
||||||
|
for (GoodsExcel vo : successArrayList){
|
||||||
|
StoreGoodsTypeDO byName = storeGoodsTypeService.getByName(vo.getCategory());
|
||||||
|
StoreGoodsSaveReqVO add = new StoreGoodsSaveReqVO();
|
||||||
|
add.setGoodsName(vo.getGoodsName());
|
||||||
|
add.setPrice(vo.getPrice());
|
||||||
|
add.setCarteenId(storeId);
|
||||||
|
add.setSalesModel(1);
|
||||||
|
add.setCategoryId(ObjectUtil.isNotEmpty(byName)?byName.getId():null);
|
||||||
|
storeGoodsService.createStoreGoods(add);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.excelImport.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zt
|
||||||
|
* @description <description class purpose>
|
||||||
|
* @since 2024/11/5
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class DishExcel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用名字去匹配,这里需要注意,如果名字重复,会导致只有一个字段读取到数据
|
||||||
|
*/
|
||||||
|
@ExcelProperty(index = 0)
|
||||||
|
public String type;
|
||||||
|
|
||||||
|
@ExcelProperty(index = 1)
|
||||||
|
public String name;
|
||||||
|
|
||||||
|
@ExcelProperty( index = 2)
|
||||||
|
public BigDecimal money;
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getMoney() {
|
||||||
|
return money;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMoney(BigDecimal money) {
|
||||||
|
this.money = money;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.excelImport.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
|
import com.alibaba.excel.event.AnalysisEventListener;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取excel数据
|
||||||
|
*/
|
||||||
|
public class DishExcelListener extends AnalysisEventListener<DishExcel> {
|
||||||
|
|
||||||
|
/**临时存储正常数据集合,最大存储100*/
|
||||||
|
private List<DishExcel> successDataList = Lists.newArrayListWithExpectedSize(300);
|
||||||
|
|
||||||
|
/**自定义消费者函数接口用于自定义监听器中数据组装*/
|
||||||
|
private final Consumer<List<DishExcel>> successConsumer;
|
||||||
|
|
||||||
|
public DishExcelListener(Consumer<List<DishExcel>> successConsumer) {
|
||||||
|
this.successConsumer = successConsumer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(DishExcel dishExcel, AnalysisContext analysisContext) {
|
||||||
|
successDataList.add(dishExcel);
|
||||||
|
System.out.println("数据:"+dishExcel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||||
|
if (CollectionUtils.isNotEmpty(successDataList)) {
|
||||||
|
successConsumer.accept(successDataList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.excelImport.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zt
|
||||||
|
* @description <description class purpose>
|
||||||
|
* @since 2024/11/5
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class GoodsExcel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用名字去匹配,这里需要注意,如果名字重复,会导致只有一个字段读取到数据
|
||||||
|
*/
|
||||||
|
@ExcelProperty(index = 0)
|
||||||
|
public String category;
|
||||||
|
|
||||||
|
@ExcelProperty(index = 1)
|
||||||
|
public String goodsName;
|
||||||
|
|
||||||
|
@ExcelProperty( index = 2)
|
||||||
|
public Double price;
|
||||||
|
|
||||||
|
|
||||||
|
public String getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategory(String category) {
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGoodsName() {
|
||||||
|
return goodsName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGoodsName(String goodsName) {
|
||||||
|
this.goodsName = goodsName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getPrice() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrice(Double price) {
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.excelImport.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
|
import com.alibaba.excel.event.AnalysisEventListener;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取excel数据
|
||||||
|
*/
|
||||||
|
public class GoodsExcelListener extends AnalysisEventListener<GoodsExcel> {
|
||||||
|
|
||||||
|
/**临时存储正常数据集合,最大存储100*/
|
||||||
|
private List<GoodsExcel> successDataList = Lists.newArrayListWithExpectedSize(300);
|
||||||
|
|
||||||
|
/**自定义消费者函数接口用于自定义监听器中数据组装*/
|
||||||
|
private final Consumer<List<GoodsExcel>> successConsumer;
|
||||||
|
|
||||||
|
public GoodsExcelListener(Consumer<List<GoodsExcel>> successConsumer) {
|
||||||
|
this.successConsumer = successConsumer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(GoodsExcel goodsExcel, AnalysisContext analysisContext) {
|
||||||
|
successDataList.add(goodsExcel);
|
||||||
|
System.out.println("数据:"+goodsExcel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||||
|
if (CollectionUtils.isNotEmpty(successDataList)) {
|
||||||
|
successConsumer.accept(successDataList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -24,6 +24,8 @@ public class StoreGoodsPageReqVO extends PageParam {
|
|||||||
@Schema(description = "价格", example = "11124")
|
@Schema(description = "价格", example = "11124")
|
||||||
private Double price;
|
private Double price;
|
||||||
|
|
||||||
|
private Long carteenId;
|
||||||
|
|
||||||
@Schema(description = "售卖模式")
|
@Schema(description = "售卖模式")
|
||||||
private Integer salesModel;
|
private Integer salesModel;
|
||||||
|
|
||||||
|
@ -42,5 +42,6 @@ public class StoreGoodsRespVO {
|
|||||||
|
|
||||||
private String img;
|
private String img;
|
||||||
|
|
||||||
|
private Long carteenId;
|
||||||
|
|
||||||
}
|
}
|
@ -25,6 +25,8 @@ public class StoreGoodsSaveReqVO {
|
|||||||
@Schema(description = "设备ID")
|
@Schema(description = "设备ID")
|
||||||
private String equipmentCode;
|
private String equipmentCode;
|
||||||
|
|
||||||
|
private Long carteenId;
|
||||||
|
|
||||||
private String img;
|
private String img;
|
||||||
|
|
||||||
}
|
}
|
@ -40,6 +40,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.annotation.security.PermitAll;
|
import javax.annotation.security.PermitAll;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -80,8 +81,11 @@ public class AppStoreController {
|
|||||||
|
|
||||||
@GetMapping("/mgcr/equipment/goodsList")
|
@GetMapping("/mgcr/equipment/goodsList")
|
||||||
@Operation(summary = "获取菜品库所有菜品")
|
@Operation(summary = "获取菜品库所有菜品")
|
||||||
public String getGoods(String equipmentCode) {
|
public String getGoods(String equipmentCode, HttpServletRequest request) {
|
||||||
List<StoreGoodsDO> goodsDOS = storeGoodsService.getAll(null);
|
|
||||||
|
String equipment = request.getHeader("Authorization");
|
||||||
|
Long storeId = cashregisterinfoApi.getStoreId(equipment);
|
||||||
|
List<StoreGoodsDO> goodsDOS = storeGoodsService.getByCarteenId(storeId);
|
||||||
List<StoreGoodsTypeDO> goodsTypeDOS = goodsTypeService.getAll();
|
List<StoreGoodsTypeDO> goodsTypeDOS = goodsTypeService.getAll();
|
||||||
List<StoreGoodsListVo> goodData = BeanUtils.toBean(goodsDOS, StoreGoodsListVo.class);
|
List<StoreGoodsListVo> goodData = BeanUtils.toBean(goodsDOS, StoreGoodsListVo.class);
|
||||||
List<StoreGoodsTypeListVo> categoryData = BeanUtils.toBean(goodsTypeDOS, StoreGoodsTypeListVo.class);
|
List<StoreGoodsTypeListVo> categoryData = BeanUtils.toBean(goodsTypeDOS, StoreGoodsTypeListVo.class);
|
||||||
|
@ -52,6 +52,8 @@ public class StoreGoodsDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private String equipmentCode;
|
private String equipmentCode;
|
||||||
|
|
||||||
|
|
||||||
|
private Long carteenId;
|
||||||
/**
|
/**
|
||||||
* 库存
|
* 库存
|
||||||
*/
|
*/
|
||||||
|
@ -24,6 +24,7 @@ public interface StoreGoodsMapper extends BaseMapperX<StoreGoodsDO> {
|
|||||||
.eqIfPresent(StoreGoodsDO::getPrice, reqVO.getPrice())
|
.eqIfPresent(StoreGoodsDO::getPrice, reqVO.getPrice())
|
||||||
.eqIfPresent(StoreGoodsDO::getSalesModel, reqVO.getSalesModel())
|
.eqIfPresent(StoreGoodsDO::getSalesModel, reqVO.getSalesModel())
|
||||||
.eqIfPresent(StoreGoodsDO::getEquipmentCode, reqVO.getEquipmentCode())
|
.eqIfPresent(StoreGoodsDO::getEquipmentCode, reqVO.getEquipmentCode())
|
||||||
|
.eqIfPresent(StoreGoodsDO::getCarteenId, reqVO.getCarteenId())
|
||||||
.betweenIfPresent(StoreGoodsDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(StoreGoodsDO::getCreateTime, reqVO.getCreateTime())
|
||||||
.inIfPresent(StoreGoodsDO::getGoodsId, reqVO.getIds())
|
.inIfPresent(StoreGoodsDO::getGoodsId, reqVO.getIds())
|
||||||
.orderByDesc(StoreGoodsDO::getGoodsId));
|
.orderByDesc(StoreGoodsDO::getGoodsId));
|
||||||
|
@ -2,10 +2,10 @@ package cn.iocoder.yudao.module.member.service.storegoods;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.validation.*;
|
import javax.validation.*;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.storegoods.vo.*;
|
import cn.iocoder.yudao.module.member.controller.admin.storegoods.vo.*;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.storegoods.StoreGoodsDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.storegoods.StoreGoodsDO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品 Service 接口
|
* 商品 Service 接口
|
||||||
@ -55,7 +55,10 @@ public interface StoreGoodsService {
|
|||||||
|
|
||||||
List<StoreGoodsDO> getAll(List<Integer> goodsIds);
|
List<StoreGoodsDO> getAll(List<Integer> goodsIds);
|
||||||
|
|
||||||
|
List<StoreGoodsDO> getByCarteenId(Long carteenId);
|
||||||
|
|
||||||
PageResult<StoreSaleGoodsPageVO> getSaleGoodsPage(StoreSaleGoodsPageVO pageReqVO);
|
PageResult<StoreSaleGoodsPageVO> getSaleGoodsPage(StoreSaleGoodsPageVO pageReqVO);
|
||||||
|
|
||||||
Map<Integer,StoreGoodsDO> getPrice(List<Integer> goodsIds);
|
Map<Integer,StoreGoodsDO> getPrice(List<Integer> goodsIds);
|
||||||
|
|
||||||
}
|
}
|
@ -15,8 +15,6 @@ import cn.iocoder.yudao.module.member.dal.mysql.storesalegoods.StoreSaleGoodsMap
|
|||||||
import cn.iocoder.yudao.module.member.enums.InventoryTypeEnum;
|
import cn.iocoder.yudao.module.member.enums.InventoryTypeEnum;
|
||||||
import cn.iocoder.yudao.module.member.enums.OutTypeEnum;
|
import cn.iocoder.yudao.module.member.enums.OutTypeEnum;
|
||||||
import cn.iocoder.yudao.module.member.service.storegoodsinventory.StoreGoodsInventoryService;
|
import cn.iocoder.yudao.module.member.service.storegoodsinventory.StoreGoodsInventoryService;
|
||||||
import cn.iocoder.yudao.module.system.api.carteen.CarteenApi;
|
|
||||||
import cn.iocoder.yudao.module.system.api.carteen.dto.CarteenRespDto;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
@ -27,7 +25,6 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -50,8 +47,6 @@ public class StoreGoodsServiceImpl implements StoreGoodsService {
|
|||||||
@Resource
|
@Resource
|
||||||
private StoreSaleGoodsMapper storeSaleGoodsMapper;
|
private StoreSaleGoodsMapper storeSaleGoodsMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private CarteenApi carteenApi;
|
|
||||||
@Resource
|
|
||||||
private StoreGoodsInventoryService storeGoodsInventoryService;
|
private StoreGoodsInventoryService storeGoodsInventoryService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -61,18 +56,15 @@ public class StoreGoodsServiceImpl implements StoreGoodsService {
|
|||||||
StoreGoodsDO storeGoods = BeanUtils.toBean(createReqVO, StoreGoodsDO.class);
|
StoreGoodsDO storeGoods = BeanUtils.toBean(createReqVO, StoreGoodsDO.class);
|
||||||
storeGoodsMapper.insert(storeGoods);
|
storeGoodsMapper.insert(storeGoods);
|
||||||
Integer goodsId = storeGoods.getGoodsId();
|
Integer goodsId = storeGoods.getGoodsId();
|
||||||
//给每家店添加库存
|
//给店添加库存
|
||||||
List<CarteenRespDto> carteenList = carteenApi.getCarteenList();
|
|
||||||
List<GoodsInfoReqVO> list = new ArrayList<>();
|
List<GoodsInfoReqVO> list = new ArrayList<>();
|
||||||
AddReqVO addReqVO = new AddReqVO();
|
AddReqVO addReqVO = new AddReqVO();
|
||||||
for (CarteenRespDto dto:carteenList){
|
GoodsInfoReqVO vo = new GoodsInfoReqVO();
|
||||||
GoodsInfoReqVO vo = new GoodsInfoReqVO();
|
vo.setGoodsId(goodsId);
|
||||||
vo.setGoodsId(goodsId);
|
vo.setNumber(0);
|
||||||
vo.setNumber(0);
|
vo.setWeight(0d);
|
||||||
vo.setWeight(0d);
|
vo.setCarteenId(createReqVO.getCarteenId());
|
||||||
vo.setCarteenId(dto.getId());
|
list.add(vo);
|
||||||
list.add(vo);
|
|
||||||
}
|
|
||||||
//库存
|
//库存
|
||||||
addReqVO.setList(list);
|
addReqVO.setList(list);
|
||||||
addReqVO.setType(InventoryTypeEnum.IN.getCode());
|
addReqVO.setType(InventoryTypeEnum.IN.getCode());
|
||||||
@ -130,6 +122,11 @@ public class StoreGoodsServiceImpl implements StoreGoodsService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<StoreGoodsDO> getByCarteenId(Long carteenId) {
|
||||||
|
return storeGoodsMapper.selectList(new LambdaQueryWrapper<StoreGoodsDO>().eq(StoreGoodsDO::getCarteenId, carteenId));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<StoreSaleGoodsPageVO> getSaleGoodsPage(StoreSaleGoodsPageVO pageReqVO) {
|
public PageResult<StoreSaleGoodsPageVO> getSaleGoodsPage(StoreSaleGoodsPageVO pageReqVO) {
|
||||||
|
|
||||||
@ -146,4 +143,5 @@ public class StoreGoodsServiceImpl implements StoreGoodsService {
|
|||||||
Map<Integer, StoreGoodsDO> map = goodsDOS.stream().collect(Collectors.toMap(StoreGoodsDO::getGoodsId, vo->vo));
|
Map<Integer, StoreGoodsDO> map = goodsDOS.stream().collect(Collectors.toMap(StoreGoodsDO::getGoodsId, vo->vo));
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -55,5 +55,5 @@ public interface StoreGoodsTypeService {
|
|||||||
|
|
||||||
List<StoreGoodsTypeDO> getAll();
|
List<StoreGoodsTypeDO> getAll();
|
||||||
|
|
||||||
|
StoreGoodsTypeDO getByName(String name);
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.member.service.storegoodstype;
|
package cn.iocoder.yudao.module.member.service.storegoodstype;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -75,4 +77,10 @@ public class StoreGoodsTypeServiceImpl implements StoreGoodsTypeService {
|
|||||||
public List<StoreGoodsTypeDO> getAll() {
|
public List<StoreGoodsTypeDO> getAll() {
|
||||||
return storeGoodsTypeMapper.selectList();
|
return storeGoodsTypeMapper.selectList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StoreGoodsTypeDO getByName(String name) {
|
||||||
|
List<StoreGoodsTypeDO> goodsTypeDOS = storeGoodsTypeMapper.selectList(new LambdaQueryWrapper<StoreGoodsTypeDO>().eq(StoreGoodsTypeDO::getCategoryName, name));
|
||||||
|
return CollectionUtil.isNotEmpty(goodsTypeDOS) ? goodsTypeDOS.get(0) : null;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.system.api.dish;
|
package cn.iocoder.yudao.module.system.api.dish;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.system.api.dish.dto.DishExcelDto;
|
||||||
import cn.iocoder.yudao.module.system.api.dish.dto.DishesRespDto;
|
import cn.iocoder.yudao.module.system.api.dish.dto.DishesRespDto;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -26,4 +27,9 @@ public interface DishesApi {
|
|||||||
* @Description: 根据菜品id 批量获取菜品信息
|
* @Description: 根据菜品id 批量获取菜品信息
|
||||||
*/
|
*/
|
||||||
public List<DishesRespDto> getDishInfo(List<Long> ids);
|
public List<DishesRespDto> getDishInfo(List<Long> ids);
|
||||||
|
|
||||||
|
|
||||||
|
public void exportDish(List<DishExcelDto> dishExcels,Long storeId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.api.dish.dto;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zt
|
||||||
|
* @description <description class purpose>
|
||||||
|
* @since 2024/11/5
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DishExcelDto {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用名字去匹配,这里需要注意,如果名字重复,会导致只有一个字段读取到数据
|
||||||
|
*/
|
||||||
|
public String type;
|
||||||
|
|
||||||
|
public String name;
|
||||||
|
|
||||||
|
public BigDecimal money;
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.api.dish;
|
|||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.system.api.dish.dto.DishExcelDto;
|
||||||
import cn.iocoder.yudao.module.system.api.dish.dto.DishesRespDto;
|
import cn.iocoder.yudao.module.system.api.dish.dto.DishesRespDto;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO;
|
||||||
import cn.iocoder.yudao.module.system.service.dishes.DishesService;
|
import cn.iocoder.yudao.module.system.service.dishes.DishesService;
|
||||||
@ -38,4 +39,9 @@ public class DishesApiImpl implements DishesApi {
|
|||||||
List<DishesDO> dishesList = dishesService.getDishesList(ids);
|
List<DishesDO> dishesList = dishesService.getDishesList(ids);
|
||||||
return BeanUtils.toBean(dishesList, DishesRespDto.class);
|
return BeanUtils.toBean(dishesList, DishesRespDto.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exportDish(List<DishExcelDto> dishExcels,Long storeId) {
|
||||||
|
dishesService.exportDish(dishExcels,storeId);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.dishes;
|
package cn.iocoder.yudao.module.system.service.dishes;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.system.api.dish.dto.DishExcelDto;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesPageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesPageReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesRespVO;
|
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesRespVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesSaveReqVO;
|
||||||
@ -70,4 +71,6 @@ public interface DishesService {
|
|||||||
List<DishesDO> getTodayDishes();
|
List<DishesDO> getTodayDishes();
|
||||||
|
|
||||||
List<DishesDO> getTodayDishesNew();
|
List<DishesDO> getTodayDishesNew();
|
||||||
|
|
||||||
|
void exportDish(List<DishExcelDto> dishExcels, Long storeId);
|
||||||
}
|
}
|
@ -1,11 +1,14 @@
|
|||||||
package cn.iocoder.yudao.module.system.service.dishes;
|
package cn.iocoder.yudao.module.system.service.dishes;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.system.api.dish.dto.DishExcelDto;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesPageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesPageReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesRespVO;
|
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesRespVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesSaveReqVO;
|
||||||
@ -18,13 +21,16 @@ import cn.iocoder.yudao.module.system.controller.app.dishes.vo.AppUpdateVO;
|
|||||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishesnutrition.DishesNutritionDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.dishesnutrition.DishesNutritionDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.dishesraw.DishesRawDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.dishesraw.DishesRawDO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.dishestype.DishesTypeDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.dishes.DishesMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.dishes.DishesMapper;
|
||||||
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
|
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
|
||||||
import cn.iocoder.yudao.module.system.service.deviceinfo.DeviceInfoService;
|
import cn.iocoder.yudao.module.system.service.deviceinfo.DeviceInfoService;
|
||||||
import cn.iocoder.yudao.module.system.service.dishesnutrition.DishesNutritionService;
|
import cn.iocoder.yudao.module.system.service.dishesnutrition.DishesNutritionService;
|
||||||
import cn.iocoder.yudao.module.system.service.dishesraw.DishesRawService;
|
import cn.iocoder.yudao.module.system.service.dishesraw.DishesRawService;
|
||||||
|
import cn.iocoder.yudao.module.system.service.dishestype.DishesTypeService;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import org.aspectj.weaver.ast.Var;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
@ -62,7 +68,8 @@ public class DishesServiceImpl implements DishesService {
|
|||||||
private DeviceInfoService deviceInfoService;
|
private DeviceInfoService deviceInfoService;
|
||||||
@Resource
|
@Resource
|
||||||
private HttpServletRequest httpServletRequest;
|
private HttpServletRequest httpServletRequest;
|
||||||
|
@Resource
|
||||||
|
private DishesTypeService dishesTypeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@ -321,11 +328,51 @@ public class DishesServiceImpl implements DishesService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getToday(){
|
public String getToday(){
|
||||||
LocalDate currentDate = LocalDate.now();
|
LocalDate currentDate = LocalDate.now();
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
return currentDate.format(formatter);
|
return currentDate.format(formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exportDish(List<DishExcelDto> dishExcels, Long storeId) {
|
||||||
|
|
||||||
|
for (DishExcelDto vo:dishExcels){
|
||||||
|
List<DishesDO> dishesDOS = dishesMapper.selectList(Wrappers.<DishesDO>lambdaQuery()
|
||||||
|
.eq(DishesDO::getCarteenId, storeId)
|
||||||
|
.eq(DishesDO::getDishesName, vo.getName()));
|
||||||
|
|
||||||
|
if(CollectionUtil.isNotEmpty(dishesDOS)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 插入
|
||||||
|
DishesDO dishes = new DishesDO();
|
||||||
|
dishes.setDishesName(vo.getName());
|
||||||
|
dishes.setDishesSumPrice(vo.getMoney());
|
||||||
|
dishes.setDeleted(Boolean.FALSE);
|
||||||
|
dishes.setCarteenId(storeId);
|
||||||
|
dishes.setDishesNumber(new BigDecimal("50"));
|
||||||
|
DishesTypeDO byName = dishesTypeService.getByName(vo.getType(), storeId);
|
||||||
|
dishes.setDishecType(ObjectUtil.isNotEmpty(byName)?byName.getId().toString():null);
|
||||||
|
|
||||||
|
LocalDateTime today = LocalDateTime.now();
|
||||||
|
int hour = today.getHour();
|
||||||
|
String time = dishesMapper.getTime(hour);
|
||||||
|
String dayOfWeekInChinese = getToday();
|
||||||
|
dishes.setWeekTime(dayOfWeekInChinese);
|
||||||
|
dishes.setTimeSlot(time);
|
||||||
|
//计算每g多少钱
|
||||||
|
BigDecimal dishesSumPrice = vo.getMoney();
|
||||||
|
BigDecimal dishesNumber = new BigDecimal("50");
|
||||||
|
BigDecimal div = NumberUtil.div(dishesSumPrice, dishesNumber, 2);
|
||||||
|
//避免计算出每克价格约 为0
|
||||||
|
if (div.floatValue() <= 0.00f) {
|
||||||
|
dishes.setDishesBasePrice(new BigDecimal("0.01"));
|
||||||
|
} else {
|
||||||
|
dishes.setDishesBasePrice(div);
|
||||||
|
}
|
||||||
|
dishesMapper.insert(dishes);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -67,5 +67,5 @@ public interface DishesTypeService {
|
|||||||
|
|
||||||
List<DishesTypeDO> getList();
|
List<DishesTypeDO> getList();
|
||||||
|
|
||||||
|
DishesTypeDO getByName(String name,Long carteenId);
|
||||||
}
|
}
|
@ -44,8 +44,7 @@ public class DishesTypeServiceImpl implements DishesTypeService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DishesTypeMapper dishesTypeMapper;
|
private DishesTypeMapper dishesTypeMapper;
|
||||||
@Resource
|
|
||||||
private DishesService dishesService;
|
|
||||||
@Override
|
@Override
|
||||||
public Long createDishesType(DishesTypeSaveReqVO createReqVO) {
|
public Long createDishesType(DishesTypeSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
@ -166,4 +165,13 @@ public class DishesTypeServiceImpl implements DishesTypeService {
|
|||||||
public List<DishesTypeDO> getList() {
|
public List<DishesTypeDO> getList() {
|
||||||
return dishesTypeMapper.selectList();
|
return dishesTypeMapper.selectList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DishesTypeDO getByName(String name,Long carteenId) {
|
||||||
|
LambdaQueryWrapper<DishesTypeDO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(DishesTypeDO::getDishesTypeName,name);
|
||||||
|
wrapper.eq(DishesTypeDO::getCarteenId,carteenId);
|
||||||
|
List<DishesTypeDO> dishesTypeDOS = dishesTypeMapper.selectList(wrapper);
|
||||||
|
return CollectionUtil.isNotEmpty(dishesTypeDOS)?dishesTypeDOS.get(0):null;
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user