菜品库存
This commit is contained in:
1 parent
f69ffac969
commit
89d7f13e4d
8 files changed
+65
-3
No files matched your search
+22
@@ -0,0 +1,22 @@
|
||||
package com.bsd.pjcloud.canteen.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 库存类型
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum StockTypeEnum {
|
||||
|
||||
MATERIAL("1", "食材"),
|
||||
DISH("2", "菜品"),
|
||||
ONLINE_DISH("3", "在线菜品库存")
|
||||
;
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
|
||||
|
||||
}
|
||||
+3
@@ -112,4 +112,7 @@ public class CanteenStockEntity extends Model<CanteenStockEntity> {
|
||||
*/
|
||||
@Schema(description="租户编号")
|
||||
private Long tenantId;
|
||||
|
||||
@Schema(description="部门id")
|
||||
private Long deptId;
|
||||
}
|
||||
+12
@@ -41,4 +41,16 @@ public class CanteenSpuStockVO {
|
||||
*/
|
||||
@Schema(description = "当前库存")
|
||||
private Double currentStock;
|
||||
|
||||
/**
|
||||
* 库存上限
|
||||
*/
|
||||
@Schema(description="库存上限")
|
||||
private Integer inventoryUpperLimit;
|
||||
|
||||
/**
|
||||
* 库存下限
|
||||
*/
|
||||
@Schema(description="库存下限")
|
||||
private Integer inventoryLowerLimit;
|
||||
}
|
||||
+17
-1
@@ -6,10 +6,14 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.canteen.constant.StockTypeEnum;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenDailySpuDTO;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenErpMaterialEntity;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenOnlineSpuEntity;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenStockEntity;
|
||||
import com.bsd.pjcloud.canteen.mapper.CanteenStockMapper;
|
||||
import com.bsd.pjcloud.canteen.service.CanteenStockService;
|
||||
import com.bsd.pjcloud.canteen.vo.erp.CanteenSpuSimpleVO;
|
||||
import com.bsd.pjcloud.canteen.vo.erp.CanteenSpuStockVO;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
@@ -46,6 +50,8 @@ public class CanteenSpuController {
|
||||
|
||||
private final CanteenSpuService canteenSpuService;
|
||||
|
||||
private final CanteenStockService canteenStockService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
@@ -121,7 +127,17 @@ public class CanteenSpuController {
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_add')")
|
||||
public R save(@RequestBody CanteenSpuEntity canteenSpu) {
|
||||
canteenSpu.setDeptId(SecurityUtils.getUser().getDeptId());
|
||||
Long deptId = SecurityUtils.getUser().getDeptId();
|
||||
canteenSpu.setDeptId(deptId);
|
||||
CanteenStockEntity canteenStockEntity = new CanteenStockEntity();
|
||||
canteenStockEntity.setItemId(canteenSpu.getId());
|
||||
canteenStockEntity.setItemType(StockTypeEnum.DISH.getType());
|
||||
canteenStockEntity.setBaseStock(0D);
|
||||
canteenStockEntity.setInventoryUpperLimit(0);
|
||||
canteenStockEntity.setInventoryLowerLimit(0);
|
||||
canteenStockEntity.setCurrentStock(0D);
|
||||
canteenStockEntity.setDeptId(deptId);
|
||||
canteenStockService.save(canteenStockEntity);
|
||||
return R.ok(canteenSpuService.save(canteenSpu));
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -124,7 +124,7 @@ public class CanteenStockController {
|
||||
|
||||
|
||||
@PostMapping("/canteen/ansync")
|
||||
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_add')")
|
||||
@PreAuthorize("@pms.hasPermission('canteen_canteenStock_add')" )
|
||||
public R ansyncStock() {
|
||||
|
||||
List<CanteenSpuEntity> list = canteenSpuService.list();
|
||||
@@ -135,6 +135,7 @@ public class CanteenStockController {
|
||||
canteenStockEntity.setBaseStock(0D);
|
||||
canteenStockEntity.setItemType("2");
|
||||
canteenStockEntity.setItemId(canteenSpuEntity.getId());
|
||||
canteenStockEntity.setDeptId(canteenSpuEntity.getDeptId());
|
||||
canteenStockEntity.setInventoryUpperLimit(0);
|
||||
canteenStockEntity.setInventoryLowerLimit(0);
|
||||
canteenStockService.save(canteenStockEntity);
|
||||
|
||||
+4
@@ -10,6 +10,8 @@ import com.bsd.pjcloud.canteen.vo.erp.CanteenSpuSimpleVO;
|
||||
import com.bsd.pjcloud.canteen.vo.erp.CanteenSpuStockVO;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CanteenSpuService extends IService<CanteenSpuEntity> {
|
||||
|
||||
|
||||
@@ -64,4 +66,6 @@ public interface CanteenSpuService extends IService<CanteenSpuEntity> {
|
||||
* @return 分页菜品库存VO
|
||||
*/
|
||||
Page<CanteenSpuStockVO> erpPageScope(Page page, CanteenSpuEntity canteenSpu);
|
||||
|
||||
|
||||
}
|
||||
+4
-1
@@ -188,7 +188,6 @@ public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, Canteen
|
||||
// 构建返回结果
|
||||
for (CanteenSpuEntity spu : records) {
|
||||
CanteenSpuStockVO vo = new CanteenSpuStockVO();
|
||||
// vo.setId(spu.getId());
|
||||
vo.setName(spu.getName());
|
||||
vo.setPicUrl(spu.getPicUrl());
|
||||
|
||||
@@ -198,6 +197,8 @@ public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, Canteen
|
||||
vo.setId(stock.getId());
|
||||
vo.setBaseStock(stock.getBaseStock());
|
||||
vo.setCurrentStock(stock.getCurrentStock());
|
||||
vo.setInventoryUpperLimit(stock.getInventoryUpperLimit());
|
||||
vo.setInventoryLowerLimit(stock.getInventoryLowerLimit());
|
||||
} else {
|
||||
// 如果没有对应的库存记录,则设置默认值
|
||||
vo.setBaseStock(0.0);
|
||||
@@ -220,4 +221,6 @@ public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, Canteen
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -19,5 +19,6 @@
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
<result property="deptId" column="dept_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user